package com.cyx;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author 陈裕星
 * @version 1.0
 */
public class 打包 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] arr = new int[N];
        for (int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }

        Arrays.sort(arr);
        if(M == N) System.out.println(arr[N-1]);
        else{
            
        }
    }
}
